home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char rcsid[] = "$Header: init.c,v 1.1 87/02/12 10:58:25 schoch Exp $";
- #endif
-
- #include "externs.h"
- #include <ctype.h>
-
- initdirlists ()
- {
- LIST linsert ();
- dirlist [PAWN] = (LIST) NIL;
- dirlist [KING] = linsert (linsert (linsert (linsert (linsert (linsert
- (linsert (linsert ((LIST) NIL, -10), -9), 1), 11), 10), 9), -1), -11);
- dirlist [KNIGHT] = linsert (linsert (linsert (linsert (linsert (linsert
- (linsert (linsert ((LIST)NIL, -19),-8), 12), 21), 19), 8), -12), -21);
- dirlist [BISHOP] = linsert (linsert (linsert (linsert
- ((LIST) NIL, -9), 11), 9), -11);
- dirlist [ROOK] = linsert (linsert (linsert (linsert
- ((LIST) NIL, -10), 1), 10), -1);
- dirlist [QUEEN] = linsert (linsert (linsert (linsert (linsert (linsert
- (linsert (linsert ((LIST) NIL, -10),-9), 1), 11), 10), 9), -1), -11);
- }
-
- initpiecelocs ()
- {
- piecelocs [BLACK] = linsert (linsert (linsert (linsert (linsert
- (linsert (linsert (linsert (linsert (linsert (linsert (linsert
- (linsert (linsert (linsert (linsert ((LIST) NIL, 11), 12), 13), 14)
- , 15), 16), 17), 18), 21), 22), 23), 24), 25), 26), 27), 28);
- piecelocs [WHITE] = linsert (linsert (linsert (linsert (linsert
- (linsert (linsert (linsert (linsert (linsert (linsert (linsert
- (linsert (linsert (linsert (linsert ((LIST) NIL, 71), 72), 73), 74)
- , 75), 76), 77), 78), 81), 82), 83), 84), 85), 86), 87), 88);
- kingloc [WHITE] = 85;
- kingloc [BLACK] = 15;
- }
-
-
- initboard(allpieces)
- int allpieces;
- {
- int row, col, spot, i, j;
- static u_char initwhose [100] = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 1, 1, 1, 1, 1, 1, 1, 1, 3,
- 3, 1, 1, 1, 1, 1, 1, 1, 1, 3,
- 3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
- 3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
- 3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
- 3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
- 3, 0, 0, 0, 0, 0, 0, 0, 0, 3,
- 3, 0, 0, 0, 0, 0, 0, 0, 0, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
-
- static int initoccupant [100] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 5, 3, 4, 6, 2, 4, 3, 5, 0,
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
- 0, 5, 3, 4, 6, 2, 4, 3, 5, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- if (ourcolor == WHITE)
- theircolor = BLACK;
- else if (ourcolor == BLACK)
- theircolor = WHITE;
- for (i = 0; i < 100; i++) {
- whose [i] = initwhose [i];
- occupant [i] = initoccupant [i];
- #ifdef XKS
- if (whose[i] == theircolor)
- ghost[i] = occupant[i];
- else
- ghost[i] = 0;
- #endif
- virgin[i] = TRUE;
- }
-
- #ifdef XKS
- for (i = 0; i < 32; i++)
- captured[i] = 0;
- #else
- for (row = 0; row <= 7; row++)
- for (col = 0; col <= 7; col ++) {
- if (ourcolor == WHITE) {
- i = row;
- j = col;
- } else {
- i = 7 - row;
- j = 7 - col;
- }
- spot = 10 * (row + 1) + (col + 1);
- blanksq [spot] = subwin (stdscr, sqheight, sqwidth,
- sqheight * i, sqwidth * j);
- square [spot] = subwin (stdscr, 1, 1,
- (sqheight * i) + (sqheight / 2),
- (sqwidth * j) + (sqwidth / 2));
- if (reversescr && (row + col) % 2 == 0) {
- wstandout (blanksq [spot]);
- wstandout (square [spot]);
- }
- for (i = 1; i <= sqwidth; i++)
- for (j = 1; j <= sqheight; j++)
- waddch (blanksq [spot], ' ');
- waddch (square [spot], sqcolor [(row + col) % 2]);
- }
- for (row = 1; row <= 2; row++)
- for (col = 1; col <= 8; col++) {
- if (ourcolor == WHITE)
- spot = 10 * (9 - row) + col;
- else
- spot = 10 * row + col;
- waddch (square [spot], symbol [occupant [spot]]);
- if (allpieces)
- waddch (square [99 - spot], tolower
- (symbol [occupant [99 - spot]]));
- }
- #endif XKS
- }
-